<template>
  <div class="ipc-toast">
    <div class="tips-container" :class="[showFlag? 'fade-in' : 'fade-out']">
      <div class="tips-icon-wrap">
        <img v-if="type === 'primary'" :src="primary">
        <img v-if="type === 'success'" :src="success">
        <img v-if="type === 'error'" :src="error">
        <img v-if="type === 'warning'" :src="warning">
      </div>
      <p class="text">{{ msg }}</p>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      msg: 'Hello',
      type: 'primary',
      showFlag: false,
      success:'',
      error:'',
      warning:'',
      primary:'',
    }
  }
}
</script>

<style lang="scss" scoped>
.ipc-toast {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  .tips-container {
    height: 50px;
    max-width: 50px;
    padding:8px;
    box-sizing: border-box;
    line-height: 30px;
    text-align: left;
    border-radius: 25px;
    background-color: #FFFFFF;
    box-shadow: rgba(0,0,0,.2) 0 1px 5px 0px;
    overflow: hidden;
    display: inline;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    .tips-icon-wrap{
      height: 34px;
      width: 34px;
      float: left;
      img{
        height: 34px;
        width: 34px;
      }
    }
    .text {
      display: inline;
      font-size: 14px;
      color: #222;
      line-height: 34px;
      margin: 0;
      padding:0 5px;
    }
  }
}
.fade-in {
  animation-name: fade-in;
  animation-duration: 1s;
  animation-fill-mode: both;
}
.fade-out {
  animation-name: fade-out;
  animation-duration: 0.3s;
  animation-fill-mode: both;
}
@keyframes fade-in {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  20% {
    opacity: 1;
    transform: scale(1);
  }
  28% {
    opacity: 1;
    transform: scale(0.9);
  }
  35% {
    opacity: 1;
    max-width: 50px;
    transform: scale(1);
  }
  100% {
    max-width: 500px;
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes fade-out {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.7);
  }
}
</style>